package apis_service

import (
	E "errors"
	"peilian-api/app/global/databases/tables"
	"peilian-api/app/global/errors"
	"peilian-api/app/global/variable"
	"peilian-api/app/model"

	"github.com/gin-gonic/gin"
)

type ApisService struct{}

func (as *ApisService) GetSessionQues(c *gin.Context, gsqr model.GetSessionQuesReq) (interface{}, *errors.ErrRes) {
	session_id, current_tag := gsqr.Session_id, gsqr.Current_num
	var cnt int64
	variable.DB.MySQL.Model(&tables.RealQues{}).Where("session_id=?", session_id).Count(&cnt)
	if cnt == 0 {
		return nil, errors.NewErrInfo(10002, E.New("session_id wrong"))
	}

	var rq = tables.RealQues{}
	variable.DB.MySQL.Model(&tables.RealQues{}).Where("session_id = ? and current_tag = ?", session_id, current_tag).Find(&rq)
	if rq.ID == 0 {
		return nil, errors.NewErrInfo(10002, E.New("Session Question is not exsit"))
	}

	return "", nil
}
